<?php
/**
 * @file
 * Help module integration.
 */

/**
 * Implements hook_help().
 */
function mobile_codes_help($path, $arg) {
  switch ($path) {
    case 'admin/help#mobile_codes':
      ctools_include('export');
      foreach (ctools_export_crud_load_all('mobile_codes_presets') as $preset) {
        if (isset($preset->disabled) && !$preset->disabled) {
          $active_preset = $preset;
          break;
        }
      }
      $mobile_code = isset($active_preset) ? theme('mobilecode', array('data' => 'http://stuar.tc/lark/s/module/s/mobile_codes', 'attributes' => array('#preset' => $active_preset->name), 'image_attributes' => array('style' => 'float: right;'))) : '';

      return $mobile_code
           . "<p>\n"
           . '  ' . t('The Mobile Codes module provides the ability to render Text, URLs or any other form of informaton as a Mobile Code, including but not limited to the QR and Datamatrix formats, providing a simple way of transfering said information from the screen to a Mobile phone.') . "\n"
           . "</p>\n"
           . "<p>&nbsp;</p>\n"
           . '<h3>' . t('Creating Mobile Codes') . "</h3>\n"
           . "<p>\n"
           . '  ' . t('Mobile Codes can be created via a few different methods') . ":\n"
           . "</p>\n"
           . "<ul>\n"
           . "  <li>\n"
           . '    <strong>' . t('Node psuedo field') . "</strong>\n"
           . "    <p>\n"
           . '      ' . t('A node pseudo field can be enabled and configured on each content type via the content types edit page, and then positioned via the <em>Display fields</em> page.') . "\n"
           . "    </p>\n"
           . "    <p>&nbsp;</p>\n"
           . "  </li>\n"
           . "  <li>\n"
           . '    <strong>' . t('Field formatters') . "</strong>\n"
           . "    <p>\n"
           . '      ' . t('A Field formatter is automatically created for each Mobile Codes Preset, the formatters are available for use with the following field types') . ":\n"
           . "    </p>\n"
           . "    <ul>\n"
           . '      <li>' . t('File field') . "</li>\n"
           . '      <li>' . t('Image field') . "</li>\n"
           . '      <li>' . t('!link module field', array('!link' => l(t('Link'), 'http://drupal.org/project/link'))) . "</li>\n"
           . '      <li>' . t('Text field') . "</li>\n"
           . "    </ul>\n"
           . "    <p>\n"
           . '      ' . t('Formatters can be assigned either via a Field UI Display settings page or on a View.') . "\n"
           . "    </p>\n"
           . "    <p>&nbsp;</p>\n"
           . "  </li>\n"
           . "  <li>\n"
           . '    <strong>' . t('Input filter') . "</strong>\n"
           . "    <p>\n"
           . '      ' . t('For use inside a Node body, or any Text fields using an Text format, Mobile Codes can be generated using the following format') . ":<br />\n"
           . "      <code>\n"
           . "        [mobilecode #preset='<strong>preset</strong>']<strong>data</strong>[/mobilecode]\n"
           . "      </code>\n"
           . "    </p>\n"
           . "    <p>\n"
           . '      <strong>' . t('Note') . ':</strong> ' . t('Be sure to enable the <em>Mobile Codes</em> filter on all required Text formats and if the <em>Limit allowed HTML tags</em> is enabled that you allows for the &lt;img&gt; tag.') . "\n"
           . "    </p>\n"
           . "    <p>&nbsp;</p>\n"
           . "  </li>\n"
           . "  <li>\n"
           . '    <strong>' . t('theme_mobilecode()') . "</strong>\n"
           . "    <p>\n"
           . '      ' . t('For use in code, the theme function can be called directly with the following format') . ":<br />\n"
           . "      <code>theme('mobilecode', array('data' => <strong>\$data</strong>, 'attributes' => array('#preset' => <strong>\$preset</strong>)))</code>\n"
           . "    </p>\n"
           . "    <p>&nbsp;</p>\n"
           . "  </li>\n"
           . "</ul>\n"
           . "<p>&nbsp;</p>\n"
           . '<h3>' . t('General configuration') . "</h3>\n"
           . "<p>\n"
           . '  ' . t('General configuration for Mobile Codes can be found at:') . "<br />\n"
           . '  &nbsp;&nbsp;' . l(url('admin/config/content/mobile_codes', array('absolute' => TRUE)), url('admin/config/content/mobile_codes', array('absolute' => TRUE))) . "\n"
           . "</p>\n"
           . "<p>\n"
           . '  ' . t('There are three sections in the Mobile Code configuration') . ":\n"
           . "</p>\n"
           . "<ul>\n"
           . "  <li>\n"
           . '    <strong>' . t('Presets') . "</strong>\n"
           . "    <p>\n"
           . '      ' . t('Presets contain the required settings for a chosen Provider, defining the Size, Color or any other available attribute available to the Provider.') . "\n"
           . "    </p>\n"
           . "    <p>\n"
           . '      ' . t('Required settings for a Preset is completely reliant on the chosen Provider.') . "\n"
           . "    </p>\n"
           . "    <p>\n"
           . '      ' . t('If the Image module is enabled you can also choose an Image style to be applied to the generated Mobile code.') . "\n"
           . "    </p>\n"
           . "    <p>&nbsp;</p>\n"
           . "  </li>\n"
           . "  <li><strong>" . t('Providers') . "</strong>\n"
           . "    <p>\n"
           . '      ' . t('Providers are the service providers that create the Mobile Codes.') . "\n"
           . "    </p>\n"
           . "    <p>\n"
           . '      ' . t('A provider can be either external (like !nokia or !google) or internal (like the !phpqrcode library), but the configuration is the same:', array('!nokia' => l(t('Nokia Mobile Codes'), 'http://mobilecodes.nokia.com'), '!google' => l(t('Google QR Codes'), 'https://code.google.com/apis/chart/docs/gallery/qr_codes.html'), '!phpqrcode' => l(t('PHP QR Code'), 'http://phpqrcode.sourceforge.net/'))) . "\n"
           . "    </p>\n"
           . "    <ol>\n"
           . "      <li>\n"
           . '        ' . t('Add an API URL with the user-definable attributes replaced with tokens') . "\n"
           . "        <p>\n"
           . '          <strong>' . t('Example') . ":</strong><br />\n"
           . "          https://chart.googleapis.com/chart?chs=[width]x[height]&cht=qr&chl=[data]&choe=[output_encoding]\n"
           . "        </p>\n"
           . "      </li>\n"
           . "      <li>\n"
           . '        ' . t('Provide the required settings for attributes') . ":\n"
           . "        <dl>\n"
           . '          <dt><strong>' . t('Label') . "</strong></dt>\n"
           . '          <dd>' . t('The human readable name of the attribute.') . "</dd>\n"
           . '          <dt><strong>' . t('Type') . "</strong></dt>\n"
           . '          <dd>' . t('The type of field to provide to the Presets form.') . "</dd>\n"
           . '          <dt><strong>' . t('Values') . "</strong></dt>\n"
           . '          <dd>' . t('The available values (formatted as "key|label", one item per line) to provide the Presets form if the Type is "Selectbox".') . "</dd>\n"
           . "        </dl>\n"
           . "      </li>\n"
           . "    </ol>\n"
           . '    <strong>' . t('Note') . ':</strong> ' . t('There should always be one attribute with the Type "Data", otherwise the Mobile Codes content will not be user-definable.') . "\n"
           . "    <p>&nbsp;</p>\n"
           . "  </li>\n"
           . "  <li><strong>" . t('Settings') . "</strong>\n"
           . "    <p>\n"
           . '      ' . t('All other general settings, such as Data type based alterations, can be found here. Additional settings can be added by third-party modules.') . "\n"
           . "    </p>\n"
           . "  </li>\n"
           . "</ul>\n"
           . "<p>&nbsp;</p>\n"
           . '<h3>' . t('Setting up the PHP QR Code library') . "</h3>\n"
           . "<p>\n"
           . '  ' . t('The PHP QR Code library is an opensource PHP based QR Code generator that can be used to create QR Codes locally instead of relying on an external Mobile Code generator.') . "\n"
           . "</p>\n"
           . "<p>\n"
           . '  ' . t('Follow these steps to set it up') . ":\n"
           . "</p>\n"
           . "<ol>\n"
           . '  <li>' . t('Download, install and enable the !libraries module.', array('!libraries' => l(t('Libraries API'), 'http://drupal.org/project/libraries'))) . "</li>\n"
           . '  <li>' . t('Download the !phpqrcode library.', array('!phpqrcode' => l(t('PHP QR Code'), 'http://sourceforge.net/projects/phpqrcode/files/releases/phpqrcode-2010100721_1.1.4.zip/download'))) . "</li>\n"
           . "  <li>\n"
           . '    ' . t('Extract the PHP QR Code library to your Libraries directory.') . "<br />\n"
           . "    <strong>e.g.,</strong> sites/all/libraries/phpqrcode\n"
           . "  </li>\n"
           . '  <li>' . t('Clear cached data from the !performance page.', array('!performance' => l(t('Performance'), 'admin/config/development/performance'))) . "</li>\n"
           . "</ol>\n"
           . "<p>&nbsp;</p>\n";
  }
}
